<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE FlexibleContexts #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE RankNTypes #-}</span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# LANGUAGE DeriveGeneric #-}</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# LANGUAGE BangPatterns #-}</span><span>
</span><span id="line-7"></span><span>
</span><span id="line-8"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Module      :  Distribution.Simple.Utils</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Copyright   :  Isaac Jones, Simon Marlow 2003-2004</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- License     :  BSD3</span><span>
</span><span id="line-13"></span><span class="hs-comment">--                portions Copyright (c) 2007, Galois Inc.</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Maintainer  :  cabal-devel@haskell.org</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- A large and somewhat miscellaneous collection of utility functions used</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- throughout the rest of the Cabal lib and in other tools that use the Cabal</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- lib like @cabal-install@. It has a very simple set of logging actions. It</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- has low level functions for running programs, a bunch of wrappers for</span><span>
</span><span id="line-22"></span><span class="hs-comment">-- various directory and file functions that do extra logging.</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Distribution.Utils.Generic</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><span class="hs-comment">-- * reading and writing files safely</span></span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#withFileContents"><span class="hs-identifier">withFileContents</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#writeFileAtomic"><span class="hs-identifier">writeFileAtomic</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Unicode</span></span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Conversions</span></span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#fromUTF8BS"><span class="hs-identifier">fromUTF8BS</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#fromUTF8LBS"><span class="hs-identifier">fromUTF8LBS</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#toUTF8BS"><span class="hs-identifier">toUTF8BS</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#toUTF8LBS"><span class="hs-identifier">toUTF8LBS</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#validateUTF8"><span class="hs-identifier">validateUTF8</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** File I/O</span></span><span>
</span><span id="line-41"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#readUTF8File"><span class="hs-identifier">readUTF8File</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#withUTF8FileContents"><span class="hs-identifier">withUTF8FileContents</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#writeUTF8File"><span class="hs-identifier">writeUTF8File</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** BOM</span></span><span>
</span><span id="line-46"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#ignoreBOM"><span class="hs-identifier">ignoreBOM</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-47"></span><span>
</span><span id="line-48"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Misc</span></span><span>
</span><span id="line-49"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#normaliseLineEndings"><span class="hs-identifier">normaliseLineEndings</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-50"></span><span>
</span><span id="line-51"></span><span>        </span><span class="annot"><span class="hs-comment">-- * generic utils</span></span><span>
</span><span id="line-52"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#dropWhileEndLE"><span class="hs-identifier">dropWhileEndLE</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-53"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#takeWhileEndLE"><span class="hs-identifier">takeWhileEndLE</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-54"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#equating"><span class="hs-identifier">equating</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-55"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Ord.html#comparing"><span class="hs-identifier">comparing</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-56"></span><span>        </span><span class="annot"><a href="../../base/src/Data.OldList.html#isInfixOf"><span class="hs-identifier">isInfixOf</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-57"></span><span>        </span><span class="annot"><a href="../../base/src/Data.OldList.html#intercalate"><span class="hs-identifier">intercalate</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-58"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#lowercase"><span class="hs-identifier">lowercase</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-59"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#isAscii"><span class="hs-identifier">isAscii</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-60"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#isAsciiAlpha"><span class="hs-identifier">isAsciiAlpha</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-61"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#isAsciiAlphaNum"><span class="hs-identifier">isAsciiAlphaNum</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-62"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#listUnion"><span class="hs-identifier">listUnion</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-63"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#listUnionRight"><span class="hs-identifier">listUnionRight</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-64"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#ordNub"><span class="hs-identifier">ordNub</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-65"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#ordNubBy"><span class="hs-identifier">ordNubBy</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-66"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#ordNubRight"><span class="hs-identifier">ordNubRight</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-67"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#safeHead"><span class="hs-identifier">safeHead</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-68"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#safeTail"><span class="hs-identifier">safeTail</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-69"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#safeLast"><span class="hs-identifier">safeLast</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-70"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#safeInit"><span class="hs-identifier">safeInit</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-71"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#unintersperse"><span class="hs-identifier">unintersperse</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-72"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#wrapText"><span class="hs-identifier">wrapText</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-73"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#wrapLine"><span class="hs-identifier">wrapLine</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-74"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#unfoldrM"><span class="hs-identifier">unfoldrM</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-75"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#spanMaybe"><span class="hs-identifier">spanMaybe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-76"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#breakMaybe"><span class="hs-identifier">breakMaybe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-77"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#unsnoc"><span class="hs-identifier">unsnoc</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-78"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#unsnocNE"><span class="hs-identifier">unsnocNE</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Triples</span></span><span>
</span><span id="line-81"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#fstOf3"><span class="hs-identifier">fstOf3</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-82"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#sndOf3"><span class="hs-identifier">sndOf3</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-83"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#trdOf3"><span class="hs-identifier">trdOf3</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span>        </span><span class="annot"><span class="hs-comment">-- * FilePath stuff</span></span><span>
</span><span id="line-86"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#isAbsoluteOnAnyPlatform"><span class="hs-identifier">isAbsoluteOnAnyPlatform</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-87"></span><span>        </span><span class="annot"><a href="Distribution.Utils.Generic.html#isRelativeOnAnyPlatform"><span class="hs-identifier">isRelativeOnAnyPlatform</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-88"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-89"></span><span>
</span><span id="line-90"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-91"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Compat.Prelude.html"><span class="hs-identifier">Distribution.Compat.Prelude</span></a></span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Utils.String.html"><span class="hs-identifier">Distribution.Utils.String</span></a></span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#"><span class="hs-identifier">Data.Bits</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator">(.&amp;.)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator">(.|.)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#shiftL"><span class="hs-identifier">shiftL</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-96"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>
</span><span id="line-97"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#isInfixOf"><span class="hs-identifier">isInfixOf</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-98"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.html#"><span class="hs-identifier">Data.Set</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Set</span></span><span>
</span><span id="line-99"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.html#"><span class="hs-identifier">Data.ByteString</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">SBS</span></span><span>
</span><span id="line-100"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.html#"><span class="hs-identifier">Data.ByteString.Lazy</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LBS</span></span><span>
</span><span id="line-101"></span><span>
</span><span id="line-102"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#"><span class="hs-identifier">System.Directory</span></a></span><span>
</span><span id="line-103"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#removeFile"><span class="hs-identifier">removeFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#renameFile"><span class="hs-identifier">renameFile</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.html#"><span class="hs-identifier">System.FilePath</span></a></span><span>
</span><span id="line-105"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#%3C.%3E"><span class="hs-operator">(&lt;.&gt;)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../filepath/src/System.FilePath.Windows.html#splitFileName"><span class="hs-identifier">splitFileName</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span>
</span><span id="line-107"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#withFile"><span class="hs-identifier">withFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#withBinaryFile"><span class="hs-identifier">withBinaryFile</span></a></span><span>
</span><span id="line-108"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#openBinaryTempFileWithDefaultPermissions"><span class="hs-identifier">openBinaryTempFileWithDefaultPermissions</span></a></span><span>
</span><span id="line-109"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.IOMode.html#IOMode"><span class="hs-identifier">IOMode</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.IOMode.html#ReadMode"><span class="hs-identifier">ReadMode</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Text.html#hGetContents"><span class="hs-identifier">hGetContents</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier">hClose</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Exception</span></span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- Helper functions</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span class="hs-comment">-- | Wraps text to the default line width. Existing newlines are preserved.</span><span>
</span><span id="line-116"></span><span class="annot"><a href="Distribution.Utils.Generic.html#wrapText"><span class="hs-identifier hs-type">wrapText</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-117"></span><span id="wrapText"><span class="annot"><span class="annottext">wrapText :: String -&gt; String
</span><a href="Distribution.Utils.Generic.html#wrapText"><span class="hs-identifier hs-var hs-var">wrapText</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; String
</span><a href="../../base/src/Data.OldList.html#unlines"><span class="hs-identifier hs-var">unlines</span></a></span><span>
</span><span id="line-118"></span><span>         </span><span class="annot"><span class="annottext">([String] -&gt; String) -&gt; (String -&gt; [String]) -&gt; String -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; String) -&gt; [String] -&gt; [String]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; String
forall a. [a] -&gt; [[a]] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#intercalate"><span class="hs-identifier hs-var">intercalate</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\n&quot;</span></span><span>
</span><span id="line-119"></span><span>              </span><span class="annot"><span class="annottext">([String] -&gt; String) -&gt; (String -&gt; [String]) -&gt; String -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">([String] -&gt; String) -&gt; [[String]] -&gt; [String]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">[String] -&gt; String
</span><a href="../../base/src/Data.OldList.html#unwords"><span class="hs-identifier hs-var">unwords</span></a></span><span>
</span><span id="line-120"></span><span>              </span><span class="annot"><span class="annottext">([[String]] -&gt; [String])
-&gt; (String -&gt; [[String]]) -&gt; String -&gt; [String]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; [String] -&gt; [[String]]
</span><a href="Distribution.Utils.Generic.html#wrapLine"><span class="hs-identifier hs-var">wrapLine</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">79</span></span><span>
</span><span id="line-121"></span><span>              </span><span class="annot"><span class="annottext">([String] -&gt; [[String]])
-&gt; (String -&gt; [String]) -&gt; String -&gt; [[String]]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String]
</span><a href="../../base/src/Data.OldList.html#words"><span class="hs-identifier hs-var">words</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-122"></span><span>         </span><span class="annot"><span class="annottext">([String] -&gt; [String])
-&gt; (String -&gt; [String]) -&gt; String -&gt; [String]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String]
</span><a href="../../base/src/Data.OldList.html#lines"><span class="hs-identifier hs-var">lines</span></a></span><span>
</span><span id="line-123"></span><span>
</span><span id="line-124"></span><span class="hs-comment">-- | Wraps a list of words to a list of lines of words of a particular width.</span><span>
</span><span id="line-125"></span><span class="annot"><a href="Distribution.Utils.Generic.html#wrapLine"><span class="hs-identifier hs-type">wrapLine</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span class="hs-special">]</span><span>
</span><span id="line-126"></span><span id="wrapLine"><span class="annot"><span class="annottext">wrapLine :: Int -&gt; [String] -&gt; [[String]]
</span><a href="Distribution.Utils.Generic.html#wrapLine"><span class="hs-identifier hs-var hs-var">wrapLine</span></a></span></span><span> </span><span id="local-6989586621679617100"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617100"><span class="hs-identifier hs-var">width</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [String] -&gt; [String] -&gt; [[String]]
</span><a href="#local-6989586621679617099"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span class="annot"><a href="#local-6989586621679617099"><span class="hs-identifier hs-type">wrap</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span class="hs-special">]</span><span>
</span><span id="line-128"></span><span>        </span><span id="local-6989586621679617099"><span class="annot"><span class="annottext">wrap :: Int -&gt; [String] -&gt; [String] -&gt; [[String]]
</span><a href="#local-6989586621679617099"><span class="hs-identifier hs-var hs-var">wrap</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>   </span><span class="hs-special">[</span><span class="hs-special">]</span><span>   </span><span class="hs-special">(</span><span id="local-6989586621679617098"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617098"><span class="hs-identifier hs-var">w</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679617097"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617097"><span class="hs-identifier hs-var">ws</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-129"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617098"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617100"><span class="hs-identifier hs-var">width</span></a></span><span>
</span><span id="line-130"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [String] -&gt; [String] -&gt; [[String]]
</span><a href="#local-6989586621679617099"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617098"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617098"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617097"><span class="hs-identifier hs-var">ws</span></a></span><span>
</span><span id="line-131"></span><span>        </span><span class="annot"><a href="#local-6989586621679617099"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span id="local-6989586621679617093"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617093"><span class="hs-identifier hs-var">col</span></a></span></span><span> </span><span id="local-6989586621679617092"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617092"><span class="hs-identifier hs-var">line</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679617091"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617091"><span class="hs-identifier hs-var">w</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679617090"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617090"><span class="hs-identifier hs-var">ws</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-132"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617093"><span class="hs-identifier hs-var">col</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617091"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617100"><span class="hs-identifier hs-var">width</span></a></span><span>
</span><span id="line-133"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; [String]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617092"><span class="hs-identifier hs-var">line</span></a></span><span> </span><span class="annot"><span class="annottext">[String] -&gt; [[String]] -&gt; [[String]]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; [String] -&gt; [String] -&gt; [[String]]
</span><a href="#local-6989586621679617099"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617091"><span class="hs-identifier hs-var">w</span></a></span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; [String]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617090"><span class="hs-identifier hs-var">ws</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-134"></span><span>        </span><span class="annot"><a href="#local-6989586621679617099"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span id="local-6989586621679617088"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617088"><span class="hs-identifier hs-var">col</span></a></span></span><span> </span><span id="local-6989586621679617087"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617087"><span class="hs-identifier hs-var">line</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679617086"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617086"><span class="hs-identifier hs-var">w</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679617085"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617085"><span class="hs-identifier hs-var">ws</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-135"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679617080"><span class="annot"><span class="annottext">col' :: Int
</span><a href="#local-6989586621679617080"><span class="hs-identifier hs-var hs-var">col'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617088"><span class="hs-identifier hs-var">col</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617086"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-136"></span><span>             </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [String] -&gt; [String] -&gt; [[String]]
</span><a href="#local-6989586621679617099"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617080"><span class="hs-identifier hs-var">col'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617086"><span class="hs-identifier hs-var">w</span></a></span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; [String]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617087"><span class="hs-identifier hs-var">line</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617085"><span class="hs-identifier hs-var">ws</span></a></span><span>
</span><span id="line-137"></span><span>        </span><span class="annot"><a href="#local-6989586621679617099"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>   </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-138"></span><span>        </span><span class="annot"><a href="#local-6989586621679617099"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679617079"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617079"><span class="hs-identifier hs-var">line</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">[String] -&gt; [String]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679617079"><span class="hs-identifier hs-var">line</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-139"></span><span>
</span><span id="line-140"></span><span class="hs-comment">-----------------------------------</span><span>
</span><span id="line-141"></span><span class="hs-comment">-- Safely reading and writing files</span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="hs-comment">-- | Gets the contents of a file, but guarantee that it gets closed.</span><span>
</span><span id="line-144"></span><span class="hs-comment">--</span><span>
</span><span id="line-145"></span><span class="hs-comment">-- The file is read lazily but if it is not fully consumed by the action then</span><span>
</span><span id="line-146"></span><span class="hs-comment">-- the remaining input is truncated and the file is closed.</span><span>
</span><span id="line-147"></span><span class="hs-comment">--</span><span>
</span><span id="line-148"></span><span id="local-6989586621679617334"><span class="annot"><a href="Distribution.Utils.Generic.html#withFileContents"><span class="hs-identifier hs-type">withFileContents</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679617334"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679617334"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-149"></span><span id="withFileContents"><span class="annot"><span class="annottext">withFileContents :: forall a. String -&gt; (String -&gt; IO a) -&gt; IO a
</span><a href="Distribution.Utils.Generic.html#withFileContents"><span class="hs-identifier hs-var hs-var">withFileContents</span></a></span></span><span> </span><span id="local-6989586621679617076"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617076"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621679617075"><span class="annot"><span class="annottext">String -&gt; IO a
</span><a href="#local-6989586621679617075"><span class="hs-identifier hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-150"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; IOMode -&gt; (Handle -&gt; IO a) -&gt; IO a
forall r. String -&gt; IOMode -&gt; (Handle -&gt; IO r) -&gt; IO r
</span><a href="../../base/src/System.IO.html#withFile"><span class="hs-identifier hs-var">withFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617076"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#ReadMode"><span class="hs-identifier hs-var">ReadMode</span></a></span><span>
</span><span id="line-151"></span><span>           </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679617074"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679617074"><span class="hs-identifier hs-var">hnd</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO String
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetContents"><span class="hs-identifier hs-var">hGetContents</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679617074"><span class="hs-identifier hs-var">hnd</span></a></span><span> </span><span class="annot"><span class="annottext">IO String -&gt; (String -&gt; IO a) -&gt; IO a
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; IO a
</span><a href="#local-6989586621679617075"><span class="hs-identifier hs-var">action</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span class="hs-comment">-- | Writes a file atomically.</span><span>
</span><span id="line-154"></span><span class="hs-comment">--</span><span>
</span><span id="line-155"></span><span class="hs-comment">-- The file is either written successfully or an IO exception is raised and</span><span>
</span><span id="line-156"></span><span class="hs-comment">-- the original file is left unchanged.</span><span>
</span><span id="line-157"></span><span class="hs-comment">--</span><span>
</span><span id="line-158"></span><span class="hs-comment">-- On windows it is not possible to delete a file that is open by a process.</span><span>
</span><span id="line-159"></span><span class="hs-comment">-- This case will give an IO exception but the atomic property is not affected.</span><span>
</span><span id="line-160"></span><span class="hs-comment">--</span><span>
</span><span id="line-161"></span><span class="annot"><a href="Distribution.Utils.Generic.html#writeFileAtomic"><span class="hs-identifier hs-type">writeFileAtomic</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">LBS.ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-162"></span><span id="writeFileAtomic"><span class="annot"><span class="annottext">writeFileAtomic :: String -&gt; ByteString -&gt; IO ()
</span><a href="Distribution.Utils.Generic.html#writeFileAtomic"><span class="hs-identifier hs-var hs-var">writeFileAtomic</span></a></span></span><span> </span><span id="local-6989586621679617073"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617073"><span class="hs-identifier hs-var">targetPath</span></a></span></span><span> </span><span id="local-6989586621679617072"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617072"><span class="hs-identifier hs-var">content</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-163"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679617071"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617071"><span class="hs-identifier hs-var">targetDir</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679617070"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617070"><span class="hs-identifier hs-var">targetFile</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (String, String)
</span><a href="../../filepath/src/System.FilePath.Windows.html#splitFileName"><span class="hs-identifier hs-var">splitFileName</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617073"><span class="hs-identifier hs-var">targetPath</span></a></span><span>
</span><span id="line-164"></span><span>  </span><span class="annot"><span class="annottext">IO (String, Handle)
-&gt; ((String, Handle) -&gt; IO ())
-&gt; ((String, Handle) -&gt; IO ())
-&gt; IO ()
forall a b c. IO a -&gt; (a -&gt; IO b) -&gt; (a -&gt; IO c) -&gt; IO c
</span><a href="../../base/src/Control.Exception.Base.html#bracketOnError"><span class="hs-identifier hs-var">Exception.bracketOnError</span></a></span><span>
</span><span id="line-165"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; String -&gt; IO (String, Handle)
</span><a href="../../base/src/System.IO.html#openBinaryTempFileWithDefaultPermissions"><span class="hs-identifier hs-var">openBinaryTempFileWithDefaultPermissions</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617071"><span class="hs-identifier hs-var">targetDir</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; IO (String, Handle)) -&gt; String -&gt; IO (String, Handle)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617070"><span class="hs-identifier hs-var">targetFile</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
</span><a href="../../filepath/src/System.FilePath.Windows.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tmp&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-166"></span><span>    </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621679617068"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617068"><span class="hs-identifier hs-var">tmpPath</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679617067"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679617067"><span class="hs-identifier hs-var">handle</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679617067"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; IO ()
</span><a href="../../directory/src/System.Directory.html#removeFile"><span class="hs-identifier hs-var">removeFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617068"><span class="hs-identifier hs-var">tmpPath</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-167"></span><span>    </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621679617066"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617066"><span class="hs-identifier hs-var">tmpPath</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679617065"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679617065"><span class="hs-identifier hs-var">handle</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-168"></span><span>        </span><span class="annot"><span class="annottext">Handle -&gt; ByteString -&gt; IO ()
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#hPut"><span class="hs-identifier hs-var">LBS.hPut</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679617065"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617072"><span class="hs-identifier hs-var">content</span></a></span><span>
</span><span id="line-169"></span><span>        </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679617065"><span class="hs-identifier hs-var">handle</span></a></span><span>
</span><span id="line-170"></span><span>        </span><span class="annot"><span class="annottext">String -&gt; String -&gt; IO ()
</span><a href="../../directory/src/System.Directory.html#renameFile"><span class="hs-identifier hs-var">renameFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617066"><span class="hs-identifier hs-var">tmpPath</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679617073"><span class="hs-identifier hs-var">targetPath</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-171"></span><span>
</span><span id="line-172"></span><span class="hs-comment">-- ------------------------------------------------------------</span><span>
</span><span id="line-173"></span><span class="hs-comment">-- * Unicode stuff</span><span>
</span><span id="line-174"></span><span class="hs-comment">-- ------------------------------------------------------------</span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span class="hs-comment">-- | Decode 'String' from UTF8-encoded 'BS.ByteString'</span><span>
</span><span id="line-177"></span><span class="hs-comment">--</span><span>
</span><span id="line-178"></span><span class="hs-comment">-- Invalid data in the UTF8 stream (this includes code-points @U+D800@</span><span>
</span><span id="line-179"></span><span class="hs-comment">-- through @U+DFFF@) will be decoded as the replacement character (@U+FFFD@).</span><span>
</span><span id="line-180"></span><span class="hs-comment">--</span><span>
</span><span id="line-181"></span><span class="annot"><a href="Distribution.Utils.Generic.html#fromUTF8BS"><span class="hs-identifier hs-type">fromUTF8BS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">SBS.ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-182"></span><span id="fromUTF8BS"><span class="annot"><span class="annottext">fromUTF8BS :: ByteString -&gt; String
</span><a href="Distribution.Utils.Generic.html#fromUTF8BS"><span class="hs-identifier hs-var hs-var">fromUTF8BS</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Word8] -&gt; String
</span><a href="Distribution.Utils.String.html#decodeStringUtf8"><span class="hs-identifier hs-var">decodeStringUtf8</span></a></span><span> </span><span class="annot"><span class="annottext">([Word8] -&gt; String)
-&gt; (ByteString -&gt; [Word8]) -&gt; ByteString -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; [Word8]
</span><a href="../../bytestring/src/Data.ByteString.html#unpack"><span class="hs-identifier hs-var">SBS.unpack</span></a></span><span>
</span><span id="line-183"></span><span>
</span><span id="line-184"></span><span class="hs-comment">-- | Variant of 'fromUTF8BS' for lazy 'BS.ByteString's</span><span>
</span><span id="line-185"></span><span class="hs-comment">--</span><span>
</span><span id="line-186"></span><span class="annot"><a href="Distribution.Utils.Generic.html#fromUTF8LBS"><span class="hs-identifier hs-type">fromUTF8LBS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">LBS.ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-187"></span><span id="fromUTF8LBS"><span class="annot"><span class="annottext">fromUTF8LBS :: ByteString -&gt; String
</span><a href="Distribution.Utils.Generic.html#fromUTF8LBS"><span class="hs-identifier hs-var hs-var">fromUTF8LBS</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Word8] -&gt; String
</span><a href="Distribution.Utils.String.html#decodeStringUtf8"><span class="hs-identifier hs-var">decodeStringUtf8</span></a></span><span> </span><span class="annot"><span class="annottext">([Word8] -&gt; String)
-&gt; (ByteString -&gt; [Word8]) -&gt; ByteString -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; [Word8]
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#unpack"><span class="hs-identifier hs-var">LBS.unpack</span></a></span><span>
</span><span id="line-188"></span><span>
</span><span id="line-189"></span><span class="hs-comment">-- | Encode 'String' to UTF8-encoded 'SBS.ByteString'</span><span>
</span><span id="line-190"></span><span class="hs-comment">--</span><span>
</span><span id="line-191"></span><span class="hs-comment">-- Code-points in the @U+D800@-@U+DFFF@ range will be encoded</span><span>
</span><span id="line-192"></span><span class="hs-comment">-- as the replacement character (i.e. @U+FFFD@).</span><span>
</span><span id="line-193"></span><span class="hs-comment">--</span><span>
</span><span id="line-194"></span><span class="annot"><a href="Distribution.Utils.Generic.html#toUTF8BS"><span class="hs-identifier hs-type">toUTF8BS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">SBS.ByteString</span></a></span><span>
</span><span id="line-195"></span><span id="toUTF8BS"><span class="annot"><span class="annottext">toUTF8BS :: String -&gt; ByteString
</span><a href="Distribution.Utils.Generic.html#toUTF8BS"><span class="hs-identifier hs-var hs-var">toUTF8BS</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Word8] -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.html#pack"><span class="hs-identifier hs-var">SBS.pack</span></a></span><span> </span><span class="annot"><span class="annottext">([Word8] -&gt; ByteString)
-&gt; (String -&gt; [Word8]) -&gt; String -&gt; ByteString
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [Word8]
</span><a href="Distribution.Utils.String.html#encodeStringUtf8"><span class="hs-identifier hs-var">encodeStringUtf8</span></a></span><span>
</span><span id="line-196"></span><span>
</span><span id="line-197"></span><span class="hs-comment">-- | Variant of 'toUTF8BS' for lazy 'BS.ByteString's</span><span>
</span><span id="line-198"></span><span class="hs-comment">--</span><span>
</span><span id="line-199"></span><span class="annot"><a href="Distribution.Utils.Generic.html#toUTF8LBS"><span class="hs-identifier hs-type">toUTF8LBS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Lazy.Internal.html#ByteString"><span class="hs-identifier hs-type">LBS.ByteString</span></a></span><span>
</span><span id="line-200"></span><span id="toUTF8LBS"><span class="annot"><span class="annottext">toUTF8LBS :: String -&gt; ByteString
</span><a href="Distribution.Utils.Generic.html#toUTF8LBS"><span class="hs-identifier hs-var hs-var">toUTF8LBS</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Word8] -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#pack"><span class="hs-identifier hs-var">LBS.pack</span></a></span><span> </span><span class="annot"><span class="annottext">([Word8] -&gt; ByteString)
-&gt; (String -&gt; [Word8]) -&gt; String -&gt; ByteString
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [Word8]
</span><a href="Distribution.Utils.String.html#encodeStringUtf8"><span class="hs-identifier hs-var">encodeStringUtf8</span></a></span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span class="hs-comment">-- | Check that strict 'ByteString' is valid UTF8. Returns 'Just offset' if it's not.</span><span>
</span><span id="line-203"></span><span class="annot"><a href="Distribution.Utils.Generic.html#validateUTF8"><span class="hs-identifier hs-type">validateUTF8</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">SBS.ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-204"></span><span id="validateUTF8"><span class="annot"><span class="annottext">validateUTF8 :: ByteString -&gt; Maybe Int
</span><a href="Distribution.Utils.Generic.html#validateUTF8"><span class="hs-identifier hs-var hs-var">validateUTF8</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ByteString -&gt; Maybe Int
</span><a href="#local-6989586621679617057"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-205"></span><span>    </span><span id="local-6989586621679617057"><span class="annot"><span class="annottext">go :: Int -&gt; ByteString -&gt; Maybe Int
</span><a href="#local-6989586621679617057"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679617016"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617016"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679617015"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617015"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; Maybe (Word8, ByteString)
</span><a href="../../bytestring/src/Data.ByteString.html#uncons"><span class="hs-identifier hs-var">SBS.uncons</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617015"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-206"></span><span>        </span><span class="annot"><span class="annottext">Maybe (Word8, ByteString)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-207"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679617013"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679617012"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617012"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-208"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x7F</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ByteString -&gt; Maybe Int
</span><a href="#local-6989586621679617057"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617016"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617012"><span class="hs-identifier hs-var">bs'</span></a></span><span>
</span><span id="line-209"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0xBF</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617016"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-210"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0xDF</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Word8 -&gt; ByteString -&gt; Maybe Int
</span><a href="#local-6989586621679617010"><span class="hs-identifier hs-var">twoBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617016"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617012"><span class="hs-identifier hs-var">bs'</span></a></span><span>
</span><span id="line-211"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0xEF</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; ByteString -&gt; Int -&gt; Maybe Int
</span><a href="#local-6989586621679617009"><span class="hs-identifier hs-var">moreBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617016"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x800</span></span><span>     </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617012"><span class="hs-identifier hs-var">bs'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Word8 -&gt; Int) -&gt; Word8 -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Word8
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0xF</span></span><span class="hs-special">)</span><span>
</span><span id="line-212"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0xF7</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; ByteString -&gt; Int -&gt; Maybe Int
</span><a href="#local-6989586621679617009"><span class="hs-identifier hs-var">moreBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617016"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x10000</span></span><span>   </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617012"><span class="hs-identifier hs-var">bs'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Word8 -&gt; Int) -&gt; Word8 -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Word8
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x7</span></span><span class="hs-special">)</span><span>
</span><span id="line-213"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0xFB</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; ByteString -&gt; Int -&gt; Maybe Int
</span><a href="#local-6989586621679617009"><span class="hs-identifier hs-var">moreBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617016"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">5</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x200000</span></span><span>  </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617012"><span class="hs-identifier hs-var">bs'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Word8 -&gt; Int) -&gt; Word8 -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Word8
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x3</span></span><span class="hs-special">)</span><span>
</span><span id="line-214"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0xFD</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; ByteString -&gt; Int -&gt; Maybe Int
</span><a href="#local-6989586621679617009"><span class="hs-identifier hs-var">moreBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617016"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">6</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x4000000</span></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617012"><span class="hs-identifier hs-var">bs'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Word8 -&gt; Int) -&gt; Word8 -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617013"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Word8
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x1</span></span><span class="hs-special">)</span><span>
</span><span id="line-215"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617016"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-216"></span><span>
</span><span id="line-217"></span><span>    </span><span id="local-6989586621679617010"><span class="annot"><span class="annottext">twoBytes :: Int -&gt; Word8 -&gt; ByteString -&gt; Maybe Int
</span><a href="#local-6989586621679617010"><span class="hs-identifier hs-var hs-var">twoBytes</span></a></span></span><span> </span><span id="local-6989586621679617008"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617008"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679617007"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617007"><span class="hs-identifier hs-var">c0</span></a></span></span><span> </span><span id="local-6989586621679617006"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617006"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; Maybe (Word8, ByteString)
</span><a href="../../bytestring/src/Data.ByteString.html#uncons"><span class="hs-identifier hs-var">SBS.uncons</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617006"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-218"></span><span>        </span><span class="annot"><span class="annottext">Maybe (Word8, ByteString)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617008"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-219"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679617005"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617005"><span class="hs-identifier hs-var">c1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679617004"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617004"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-220"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617005"><span class="hs-identifier hs-var">c1</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Word8
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0xC0</span></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x80</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-221"></span><span>                </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617003"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x80</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span>
</span><span id="line-222"></span><span>                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ByteString -&gt; Maybe Int
</span><a href="#local-6989586621679617057"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617008"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679617004"><span class="hs-identifier hs-var">bs'</span></a></span><span>
</span><span id="line-223"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617008"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-224"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679617008"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-225"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-226"></span><span>            </span><span id="local-6989586621679617003"><span class="annot"><span class="annottext">d :: Int
</span><a href="#local-6989586621679617003"><span class="hs-identifier hs-var hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617007"><span class="hs-identifier hs-var">c0</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Word8
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x1F</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="../../base/src/Data.Bits.html#shiftL"><span class="hs-operator hs-var">`shiftL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">6</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679617005"><span class="hs-identifier hs-var">c1</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Word8
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x3F</span></span><span class="hs-special">)</span><span>
</span><span id="line-227"></span><span>
</span><span id="line-228"></span><span>    </span><span class="annot"><a href="#local-6989586621679617009"><span class="hs-identifier hs-type">moreBytes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">SBS.ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-229"></span><span>    </span><span id="local-6989586621679617009"><span class="annot"><span class="annottext">moreBytes :: Int -&gt; Int -&gt; Int -&gt; ByteString -&gt; Int -&gt; Maybe Int
</span><a href="#local-6989586621679617009"><span class="hs-identifier hs-var hs-var">moreBytes</span></a></span></span><span> </span><span id="local-6989586621679616992"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616992"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span id="local-6989586621679616991"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616991"><span class="hs-identifier hs-var">overlong</span></a></span></span><span> </span><span id="local-6989586621679616990"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679616990"><span class="hs-identifier hs-var">cs'</span></a></span></span><span> </span><span id="local-6989586621679616989"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616989"><span class="hs-identifier hs-var">acc</span></a></span></span><span>
</span><span id="line-230"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616991"><span class="hs-identifier hs-var">overlong</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616989"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616989"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x10FFFF</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616989"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0xD800</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0xDFFF</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616989"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-231"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ByteString -&gt; Maybe Int
</span><a href="#local-6989586621679617057"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616992"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679616990"><span class="hs-identifier hs-var">cs'</span></a></span><span>
</span><span id="line-232"></span><span>
</span><span id="line-233"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-234"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616992"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-235"></span><span>
</span><span id="line-236"></span><span>    </span><span class="annot"><a href="#local-6989586621679617009"><span class="hs-identifier hs-var">moreBytes</span></a></span><span> </span><span id="local-6989586621679616986"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616986"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679616985"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616985"><span class="hs-identifier hs-var">byteCount</span></a></span></span><span> </span><span id="local-6989586621679616984"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616984"><span class="hs-identifier hs-var">overlong</span></a></span></span><span> </span><span id="local-6989586621679616983"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679616983"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span id="local-6989586621679616982"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616982"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; Maybe (Word8, ByteString)
</span><a href="../../bytestring/src/Data.ByteString.html#uncons"><span class="hs-identifier hs-var">SBS.uncons</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679616983"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-237"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616981"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679616981"><span class="hs-identifier hs-var">cn</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679616980"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679616980"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679616981"><span class="hs-identifier hs-var">cn</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Word8
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0xC0</span></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x80</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-238"></span><span>            </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int -&gt; ByteString -&gt; Int -&gt; Maybe Int
</span><a href="#local-6989586621679617009"><span class="hs-identifier hs-var">moreBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616986"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616985"><span class="hs-identifier hs-var">byteCount</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616984"><span class="hs-identifier hs-var">overlong</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679616980"><span class="hs-identifier hs-var">bs'</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616982"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="../../base/src/Data.Bits.html#shiftL"><span class="hs-operator hs-var">`shiftL`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">6</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679616981"><span class="hs-identifier hs-var">cn</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x3F</span></span><span class="hs-special">)</span><span>
</span><span id="line-239"></span><span>        </span><span class="annot"><span class="annottext">Maybe (Word8, ByteString)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679616986"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-240"></span><span>        </span><span>
</span><span id="line-241"></span><span>
</span><span id="line-242"></span><span class="hs-comment">-- | Ignore a Unicode byte order mark (BOM) at the beginning of the input</span><span>
</span><span id="line-243"></span><span class="hs-comment">--</span><span>
</span><span id="line-244"></span><span class="annot"><a href="Distribution.Utils.Generic.html#ignoreBOM"><span class="hs-identifier hs-type">ignoreBOM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-245"></span><span id="ignoreBOM"><span class="annot"><span class="annottext">ignoreBOM :: String -&gt; String
</span><a href="Distribution.Utils.Generic.html#ignoreBOM"><span class="hs-identifier hs-var hs-var">ignoreBOM</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\xFEFF'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616979"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616979"><span class="hs-identifier hs-var">string</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616979"><span class="hs-identifier hs-var">string</span></a></span><span>
</span><span id="line-246"></span><span class="annot"><a href="Distribution.Utils.Generic.html#ignoreBOM"><span class="hs-identifier hs-var">ignoreBOM</span></a></span><span> </span><span id="local-6989586621679616978"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616978"><span class="hs-identifier hs-var">string</span></a></span></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616978"><span class="hs-identifier hs-var">string</span></a></span><span>
</span><span id="line-247"></span><span>
</span><span id="line-248"></span><span class="hs-comment">-- | Reads a UTF8 encoded text file as a Unicode String</span><span>
</span><span id="line-249"></span><span class="hs-comment">--</span><span>
</span><span id="line-250"></span><span class="hs-comment">-- Reads lazily using ordinary 'readFile'.</span><span>
</span><span id="line-251"></span><span class="hs-comment">--</span><span>
</span><span id="line-252"></span><span class="annot"><a href="Distribution.Utils.Generic.html#readUTF8File"><span class="hs-identifier hs-type">readUTF8File</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-253"></span><span id="readUTF8File"><span class="annot"><span class="annottext">readUTF8File :: String -&gt; IO String
</span><a href="Distribution.Utils.Generic.html#readUTF8File"><span class="hs-identifier hs-var hs-var">readUTF8File</span></a></span></span><span> </span><span id="local-6989586621679616977"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616977"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="Distribution.Utils.Generic.html#ignoreBOM"><span class="hs-identifier hs-var">ignoreBOM</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; String)
-&gt; (ByteString -&gt; String) -&gt; ByteString -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; String
</span><a href="Distribution.Utils.Generic.html#fromUTF8LBS"><span class="hs-identifier hs-var">fromUTF8LBS</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(ByteString -&gt; String) -&gt; IO ByteString -&gt; IO String
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; IO ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#readFile"><span class="hs-identifier hs-var">LBS.readFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616977"><span class="hs-identifier hs-var">f</span></a></span><span>
</span><span id="line-254"></span><span>
</span><span id="line-255"></span><span class="hs-comment">-- | Reads a UTF8 encoded text file as a Unicode String</span><span>
</span><span id="line-256"></span><span class="hs-comment">--</span><span>
</span><span id="line-257"></span><span class="hs-comment">-- Same behaviour as 'withFileContents'.</span><span>
</span><span id="line-258"></span><span class="hs-comment">--</span><span>
</span><span id="line-259"></span><span id="local-6989586621679616974"><span class="annot"><a href="Distribution.Utils.Generic.html#withUTF8FileContents"><span class="hs-identifier hs-type">withUTF8FileContents</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679616974"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679616974"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-260"></span><span id="withUTF8FileContents"><span class="annot"><span class="annottext">withUTF8FileContents :: forall a. String -&gt; (String -&gt; IO a) -&gt; IO a
</span><a href="Distribution.Utils.Generic.html#withUTF8FileContents"><span class="hs-identifier hs-var hs-var">withUTF8FileContents</span></a></span></span><span> </span><span id="local-6989586621679616972"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616972"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621679616971"><span class="annot"><span class="annottext">String -&gt; IO a
</span><a href="#local-6989586621679616971"><span class="hs-identifier hs-var">action</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-261"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; IOMode -&gt; (Handle -&gt; IO a) -&gt; IO a
forall r. String -&gt; IOMode -&gt; (Handle -&gt; IO r) -&gt; IO r
</span><a href="../../base/src/System.IO.html#withBinaryFile"><span class="hs-identifier hs-var">withBinaryFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616972"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#ReadMode"><span class="hs-identifier hs-var">ReadMode</span></a></span><span>
</span><span id="line-262"></span><span>    </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679616970"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679616970"><span class="hs-identifier hs-var">hnd</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO ByteString
</span><a href="../../bytestring/src/Data.ByteString.Lazy.html#hGetContents"><span class="hs-identifier hs-var">LBS.hGetContents</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679616970"><span class="hs-identifier hs-var">hnd</span></a></span><span> </span><span class="annot"><span class="annottext">IO ByteString -&gt; (ByteString -&gt; IO a) -&gt; IO a
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; IO a
</span><a href="#local-6989586621679616971"><span class="hs-identifier hs-var">action</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; IO a) -&gt; (ByteString -&gt; String) -&gt; ByteString -&gt; IO a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="Distribution.Utils.Generic.html#ignoreBOM"><span class="hs-identifier hs-var">ignoreBOM</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; String)
-&gt; (ByteString -&gt; String) -&gt; ByteString -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; String
</span><a href="Distribution.Utils.Generic.html#fromUTF8LBS"><span class="hs-identifier hs-var">fromUTF8LBS</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-263"></span><span>
</span><span id="line-264"></span><span class="hs-comment">-- | Writes a Unicode String as a UTF8 encoded text file.</span><span>
</span><span id="line-265"></span><span class="hs-comment">--</span><span>
</span><span id="line-266"></span><span class="hs-comment">-- Uses 'writeFileAtomic', so provides the same guarantees.</span><span>
</span><span id="line-267"></span><span class="hs-comment">--</span><span>
</span><span id="line-268"></span><span class="annot"><a href="Distribution.Utils.Generic.html#writeUTF8File"><span class="hs-identifier hs-type">writeUTF8File</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-269"></span><span id="writeUTF8File"><span class="annot"><span class="annottext">writeUTF8File :: String -&gt; String -&gt; IO ()
</span><a href="Distribution.Utils.Generic.html#writeUTF8File"><span class="hs-identifier hs-var hs-var">writeUTF8File</span></a></span></span><span> </span><span id="local-6989586621679616968"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616968"><span class="hs-identifier hs-var">path</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; ByteString -&gt; IO ()
</span><a href="Distribution.Utils.Generic.html#writeFileAtomic"><span class="hs-identifier hs-var">writeFileAtomic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616968"><span class="hs-identifier hs-var">path</span></a></span><span> </span><span class="annot"><span class="annottext">(ByteString -&gt; IO ()) -&gt; (String -&gt; ByteString) -&gt; String -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ByteString
</span><a href="Distribution.Utils.Generic.html#toUTF8LBS"><span class="hs-identifier hs-var">toUTF8LBS</span></a></span><span>
</span><span id="line-270"></span><span>
</span><span id="line-271"></span><span class="hs-comment">-- | Fix different systems silly line ending conventions</span><span>
</span><span id="line-272"></span><span class="annot"><a href="Distribution.Utils.Generic.html#normaliseLineEndings"><span class="hs-identifier hs-type">normaliseLineEndings</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-273"></span><span id="normaliseLineEndings"><span class="annot"><span class="annottext">normaliseLineEndings :: String -&gt; String
</span><a href="Distribution.Utils.Generic.html#normaliseLineEndings"><span class="hs-identifier hs-var hs-var">normaliseLineEndings</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-274"></span><span class="annot"><a href="Distribution.Utils.Generic.html#normaliseLineEndings"><span class="hs-identifier hs-var">normaliseLineEndings</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\r'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\n'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616967"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616967"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\n'</span></span><span> </span><span class="annot"><span class="annottext">Char -&gt; String -&gt; String
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="Distribution.Utils.Generic.html#normaliseLineEndings"><span class="hs-identifier hs-var">normaliseLineEndings</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616967"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-comment">-- windows</span><span>
</span><span id="line-275"></span><span class="annot"><a href="Distribution.Utils.Generic.html#normaliseLineEndings"><span class="hs-identifier hs-var">normaliseLineEndings</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\r'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616966"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616966"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\n'</span></span><span> </span><span class="annot"><span class="annottext">Char -&gt; String -&gt; String
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="Distribution.Utils.Generic.html#normaliseLineEndings"><span class="hs-identifier hs-var">normaliseLineEndings</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616966"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-comment">-- old OS X</span><span>
</span><span id="line-276"></span><span class="annot"><a href="Distribution.Utils.Generic.html#normaliseLineEndings"><span class="hs-identifier hs-var">normaliseLineEndings</span></a></span><span> </span><span class="hs-special">(</span><span>  </span><span id="local-6989586621679616965"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616965"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616964"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616964"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span>   </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616965"><span class="hs-identifier hs-var">c</span></a></span><span>  </span><span class="annot"><span class="annottext">Char -&gt; String -&gt; String
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="Distribution.Utils.Generic.html#normaliseLineEndings"><span class="hs-identifier hs-var">normaliseLineEndings</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616964"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-277"></span><span>
</span><span id="line-278"></span><span class="hs-comment">-- ------------------------------------------------------------</span><span>
</span><span id="line-279"></span><span class="hs-comment">-- * Common utils</span><span>
</span><span id="line-280"></span><span class="hs-comment">-- ------------------------------------------------------------</span><span>
</span><span id="line-281"></span><span>
</span><span id="line-282"></span><span class="hs-comment">-- | @dropWhileEndLE p@ is equivalent to @reverse . dropWhile p . reverse@, but</span><span>
</span><span id="line-283"></span><span class="hs-comment">-- quite a bit faster. The difference between &quot;Data.List.dropWhileEnd&quot; and this</span><span>
</span><span id="line-284"></span><span class="hs-comment">-- version is that the one in &quot;Data.List&quot; is strict in elements, but spine-lazy,</span><span>
</span><span id="line-285"></span><span class="hs-comment">-- while this one is spine-strict but lazy in elements. That's what @LE@ stands</span><span>
</span><span id="line-286"></span><span class="hs-comment">-- for - &quot;lazy in elements&quot;.</span><span>
</span><span id="line-287"></span><span class="hs-comment">--</span><span>
</span><span id="line-288"></span><span class="hs-comment">-- Example:</span><span>
</span><span id="line-289"></span><span class="hs-comment">--</span><span>
</span><span id="line-290"></span><span class="hs-comment">-- &gt;&gt;&gt; safeTail $ Data.List.dropWhileEnd (&lt;3) [undefined, 5, 4, 3, 2, 1]</span><span>
</span><span id="line-291"></span><span class="hs-comment">-- *** Exception: Prelude.undefined</span><span>
</span><span id="line-292"></span><span class="hs-comment">-- ...</span><span>
</span><span id="line-293"></span><span class="hs-comment">--</span><span>
</span><span id="line-294"></span><span class="hs-comment">-- &gt;&gt;&gt; safeTail $ dropWhileEndLE (&lt;3) [undefined, 5, 4, 3, 2, 1]</span><span>
</span><span id="line-295"></span><span class="hs-comment">-- [5,4,3]</span><span>
</span><span id="line-296"></span><span class="hs-comment">--</span><span>
</span><span id="line-297"></span><span class="hs-comment">-- &gt;&gt;&gt; take 3 $ Data.List.dropWhileEnd (&lt;3) [5, 4, 3, 2, 1, undefined]</span><span>
</span><span id="line-298"></span><span class="hs-comment">-- [5,4,3]</span><span>
</span><span id="line-299"></span><span class="hs-comment">--</span><span>
</span><span id="line-300"></span><span class="hs-comment">-- &gt;&gt;&gt; take 3 $ dropWhileEndLE (&lt;3) [5, 4, 3, 2, 1, undefined]</span><span>
</span><span id="line-301"></span><span class="hs-comment">-- *** Exception: Prelude.undefined</span><span>
</span><span id="line-302"></span><span class="hs-comment">-- ...</span><span>
</span><span id="line-303"></span><span class="hs-comment">--</span><span>
</span><span id="line-304"></span><span id="local-6989586621679617308"><span class="annot"><a href="Distribution.Utils.Generic.html#dropWhileEndLE"><span class="hs-identifier hs-type">dropWhileEndLE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617308"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617308"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617308"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-305"></span><span id="dropWhileEndLE"><span class="annot"><span class="annottext">dropWhileEndLE :: forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#dropWhileEndLE"><span class="hs-identifier hs-var hs-var">dropWhileEndLE</span></a></span></span><span> </span><span id="local-6989586621679616961"><span class="annot"><span class="annottext">a -&gt; Bool
</span><a href="#local-6989586621679616961"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; [a] -&gt; [a]) -&gt; [a] -&gt; [a] -&gt; [a]
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679616959"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616959"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679616958"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616958"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616958"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">a -&gt; Bool
</span><a href="#local-6989586621679616961"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616959"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616959"><span class="hs-identifier hs-var">x</span></a></span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616958"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-306"></span><span>
</span><span id="line-307"></span><span class="hs-comment">-- | @takeWhileEndLE p@ is equivalent to @reverse . takeWhile p . reverse@, but</span><span>
</span><span id="line-308"></span><span class="hs-comment">-- is usually faster (as well as being easier to read).</span><span>
</span><span id="line-309"></span><span id="local-6989586621679616955"><span class="annot"><a href="Distribution.Utils.Generic.html#takeWhileEndLE"><span class="hs-identifier hs-type">takeWhileEndLE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679616955"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616955"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616955"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-310"></span><span id="takeWhileEndLE"><span class="annot"><span class="annottext">takeWhileEndLE :: forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#takeWhileEndLE"><span class="hs-identifier hs-var hs-var">takeWhileEndLE</span></a></span></span><span> </span><span id="local-6989586621679616953"><span class="annot"><span class="annottext">a -&gt; Bool
</span><a href="#local-6989586621679616953"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([a], Bool) -&gt; [a]
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(([a], Bool) -&gt; [a]) -&gt; ([a] -&gt; ([a], Bool)) -&gt; [a] -&gt; [a]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; ([a], Bool) -&gt; ([a], Bool))
-&gt; ([a], Bool) -&gt; [a] -&gt; ([a], Bool)
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; ([a], Bool) -&gt; ([a], Bool)
</span><a href="#local-6989586621679616952"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-311"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-312"></span><span>    </span><span id="local-6989586621679616952"><span class="annot"><span class="annottext">go :: a -&gt; ([a], Bool) -&gt; ([a], Bool)
</span><a href="#local-6989586621679616952"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679616951"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616951"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616950"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616950"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679616949"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679616949"><span class="hs-identifier hs-var">done</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-313"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679616949"><span class="hs-identifier hs-var">done</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">a -&gt; Bool
</span><a href="#local-6989586621679616953"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616951"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616951"><span class="hs-identifier hs-var">x</span></a></span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616950"><span class="hs-identifier hs-var">rest</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-314"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616950"><span class="hs-identifier hs-var">rest</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span>
</span><span id="line-315"></span><span>
</span><span id="line-316"></span><span class="hs-comment">-- | Like 'Data.List.nub', but has @O(n log n)@ complexity instead of</span><span>
</span><span id="line-317"></span><span class="hs-comment">-- @O(n^2)@. Code for 'ordNub' and 'listUnion' taken from Niklas Hamb&#252;chen's</span><span>
</span><span id="line-318"></span><span class="hs-comment">-- &lt;http://github.com/nh2/haskell-ordnub ordnub&gt; package.</span><span>
</span><span id="line-319"></span><span id="local-6989586621679617300"><span class="annot"><a href="Distribution.Utils.Generic.html#ordNub"><span class="hs-identifier hs-type">ordNub</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Ord</span></span><span> </span><span class="annot"><a href="#local-6989586621679617300"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617300"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617300"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-320"></span><span id="ordNub"><span class="annot"><span class="annottext">ordNub :: forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#ordNub"><span class="hs-identifier hs-var hs-var">ordNub</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; a) -&gt; [a] -&gt; [a]
forall b a. Ord b =&gt; (a -&gt; b) -&gt; [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#ordNubBy"><span class="hs-identifier hs-var">ordNubBy</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; a
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-321"></span><span>
</span><span id="line-322"></span><span class="hs-comment">-- | Like 'ordNub' and 'Data.List.nubBy'. Selects a key for each element and</span><span>
</span><span id="line-323"></span><span class="hs-comment">-- takes the nub based on that key.</span><span>
</span><span id="line-324"></span><span id="local-6989586621679617297"><span id="local-6989586621679617298"><span class="annot"><a href="Distribution.Utils.Generic.html#ordNubBy"><span class="hs-identifier hs-type">ordNubBy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Ord</span></span><span> </span><span class="annot"><a href="#local-6989586621679617298"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617297"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679617298"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617297"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617297"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span></span><span>
</span><span id="line-325"></span><span id="ordNubBy"><span class="annot"><span class="annottext">ordNubBy :: forall b a. Ord b =&gt; (a -&gt; b) -&gt; [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#ordNubBy"><span class="hs-identifier hs-var hs-var">ordNubBy</span></a></span></span><span> </span><span id="local-6989586621679616943"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679616943"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679616942"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616942"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Set b -&gt; [a] -&gt; [a]
</span><a href="#local-6989586621679616941"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Set b
forall a. Set a
</span><a href="../../containers/src/Data.Set.Internal.html#empty"><span class="hs-identifier hs-var">Set.empty</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616942"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-326"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-327"></span><span>    </span><span id="local-6989586621679616941"><span class="annot"><span class="annottext">go :: Set b -&gt; [a] -&gt; [a]
</span><a href="#local-6989586621679616941"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="annottext">Set b
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-328"></span><span>    </span><span class="annot"><a href="#local-6989586621679616941"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679616938"><span class="annot"><span class="annottext">Set b
</span><a href="#local-6989586621679616938"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616937"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616937"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616936"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616936"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616935"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">b -&gt; Set b -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">Set b
</span><a href="#local-6989586621679616938"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Set b -&gt; [a] -&gt; [a]
</span><a href="#local-6989586621679616941"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Set b
</span><a href="#local-6989586621679616938"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616936"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-330"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679616932"><span class="annot"><span class="annottext">s' :: Set b
</span><a href="#local-6989586621679616932"><span class="hs-identifier hs-var hs-var">s'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b -&gt; Set b -&gt; Set b
forall a. Ord a =&gt; a -&gt; Set a -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#insert"><span class="hs-identifier hs-var">Set.insert</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616935"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Set b
</span><a href="#local-6989586621679616938"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-331"></span><span>                            </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616937"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">Set b -&gt; [a] -&gt; [a]
</span><a href="#local-6989586621679616941"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Set b
</span><a href="#local-6989586621679616932"><span class="hs-identifier hs-var">s'</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616936"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-332"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-333"></span><span>        </span><span id="local-6989586621679616935"><span class="annot"><span class="annottext">y :: b
</span><a href="#local-6989586621679616935"><span class="hs-identifier hs-var hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679616943"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616937"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-334"></span><span>
</span><span id="line-335"></span><span class="hs-comment">-- | Like &quot;Data.List.union&quot;, but has @O(n log n)@ complexity instead of</span><span>
</span><span id="line-336"></span><span class="hs-comment">-- @O(n^2)@.</span><span>
</span><span id="line-337"></span><span id="local-6989586621679617289"><span class="annot"><a href="Distribution.Utils.Generic.html#listUnion"><span class="hs-identifier hs-type">listUnion</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Ord</span></span><span> </span><span class="annot"><a href="#local-6989586621679617289"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617289"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617289"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617289"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-338"></span><span id="listUnion"><span class="annot"><span class="annottext">listUnion :: forall a. Ord a =&gt; [a] -&gt; [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#listUnion"><span class="hs-identifier hs-var hs-var">listUnion</span></a></span></span><span> </span><span id="local-6989586621679616927"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616927"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621679616926"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616926"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616927"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a] -&gt; [a]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a]
forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#ordNub"><span class="hs-identifier hs-var">ordNub</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; Bool) -&gt; [a] -&gt; [a]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; Set a -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#notMember"><span class="hs-operator hs-var">`Set.notMember`</span></a></span><span> </span><span class="annot"><span class="annottext">Set a
</span><a href="#local-6989586621679616924"><span class="hs-identifier hs-var">aSet</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616926"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-339"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-340"></span><span>    </span><span id="local-6989586621679616924"><span class="annot"><span class="annottext">aSet :: Set a
</span><a href="#local-6989586621679616924"><span class="hs-identifier hs-var hs-var">aSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Set a
forall a. Ord a =&gt; [a] -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#fromList"><span class="hs-identifier hs-var">Set.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616927"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-341"></span><span>
</span><span id="line-342"></span><span class="hs-comment">-- | A right-biased version of 'ordNub'.</span><span>
</span><span id="line-343"></span><span class="hs-comment">--</span><span>
</span><span id="line-344"></span><span class="hs-comment">-- Example:</span><span>
</span><span id="line-345"></span><span class="hs-comment">--</span><span>
</span><span id="line-346"></span><span class="hs-comment">-- &gt;&gt;&gt; ordNub [1,2,1] :: [Int]</span><span>
</span><span id="line-347"></span><span class="hs-comment">-- [1,2]</span><span>
</span><span id="line-348"></span><span class="hs-comment">--</span><span>
</span><span id="line-349"></span><span class="hs-comment">-- &gt;&gt;&gt; ordNubRight [1,2,1] :: [Int]</span><span>
</span><span id="line-350"></span><span class="hs-comment">-- [2,1]</span><span>
</span><span id="line-351"></span><span class="hs-comment">--</span><span>
</span><span id="line-352"></span><span id="local-6989586621679616921"><span class="annot"><a href="Distribution.Utils.Generic.html#ordNubRight"><span class="hs-identifier hs-type">ordNubRight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Ord</span></span><span> </span><span class="annot"><a href="#local-6989586621679616921"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616921"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616921"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-353"></span><span id="ordNubRight"><span class="annot"><span class="annottext">ordNubRight :: forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#ordNubRight"><span class="hs-identifier hs-var hs-var">ordNubRight</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([a], Set a) -&gt; [a]
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(([a], Set a) -&gt; [a]) -&gt; ([a] -&gt; ([a], Set a)) -&gt; [a] -&gt; [a]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; ([a], Set a) -&gt; ([a], Set a))
-&gt; ([a], Set a) -&gt; [a] -&gt; ([a], Set a)
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; ([a], Set a) -&gt; ([a], Set a)
forall {a}. Ord a =&gt; a -&gt; ([a], Set a) -&gt; ([a], Set a)
</span><a href="#local-6989586621679616917"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Set a
forall a. Set a
</span><a href="../../containers/src/Data.Set.Internal.html#empty"><span class="hs-identifier hs-var">Set.empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-354"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-355"></span><span>    </span><span id="local-6989586621679616917"><span class="annot"><span class="annottext">go :: a -&gt; ([a], Set a) -&gt; ([a], Set a)
</span><a href="#local-6989586621679616917"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679616913"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616913"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679616912"><span class="annot"><span class="annottext">p :: ([a], Set a)
</span><a href="#local-6989586621679616912"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621679616911"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616911"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679616910"><span class="annot"><span class="annottext">Set a
</span><a href="#local-6989586621679616910"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616913"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Set a -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">Set a
</span><a href="#local-6989586621679616910"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">([a], Set a)
</span><a href="#local-6989586621679616912"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-356"></span><span>                                        </span><span class="hs-keyword">else</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616913"><span class="hs-identifier hs-var">x</span></a></span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616911"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a -&gt; Set a -&gt; Set a
forall a. Ord a =&gt; a -&gt; Set a -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#insert"><span class="hs-identifier hs-var">Set.insert</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616913"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Set a
</span><a href="#local-6989586621679616910"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-357"></span><span>
</span><span id="line-358"></span><span class="hs-comment">-- | A right-biased version of 'listUnion'.</span><span>
</span><span id="line-359"></span><span class="hs-comment">--</span><span>
</span><span id="line-360"></span><span class="hs-comment">-- Example:</span><span>
</span><span id="line-361"></span><span class="hs-comment">--</span><span>
</span><span id="line-362"></span><span class="hs-comment">-- &gt;&gt;&gt; listUnion [1,2,3,4,3] [2,1,1]</span><span>
</span><span id="line-363"></span><span class="hs-comment">-- [1,2,3,4,3]</span><span>
</span><span id="line-364"></span><span class="hs-comment">--</span><span>
</span><span id="line-365"></span><span class="hs-comment">-- &gt;&gt;&gt; listUnionRight [1,2,3,4,3] [2,1,1]</span><span>
</span><span id="line-366"></span><span class="hs-comment">-- [4,3,2,1,1]</span><span>
</span><span id="line-367"></span><span class="hs-comment">--</span><span>
</span><span id="line-368"></span><span id="local-6989586621679616909"><span class="annot"><a href="Distribution.Utils.Generic.html#listUnionRight"><span class="hs-identifier hs-type">listUnionRight</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Ord</span></span><span> </span><span class="annot"><a href="#local-6989586621679616909"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616909"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616909"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616909"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-369"></span><span id="listUnionRight"><span class="annot"><span class="annottext">listUnionRight :: forall a. Ord a =&gt; [a] -&gt; [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#listUnionRight"><span class="hs-identifier hs-var hs-var">listUnionRight</span></a></span></span><span> </span><span id="local-6989586621679616905"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616905"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621679616904"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616904"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a]
forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#ordNubRight"><span class="hs-identifier hs-var">ordNubRight</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; Bool) -&gt; [a] -&gt; [a]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; Set a -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#notMember"><span class="hs-operator hs-var">`Set.notMember`</span></a></span><span> </span><span class="annot"><span class="annottext">Set a
</span><a href="#local-6989586621679616903"><span class="hs-identifier hs-var">bSet</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616905"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a] -&gt; [a]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616904"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-370"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-371"></span><span>    </span><span id="local-6989586621679616903"><span class="annot"><span class="annottext">bSet :: Set a
</span><a href="#local-6989586621679616903"><span class="hs-identifier hs-var hs-var">bSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Set a
forall a. Ord a =&gt; [a] -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#fromList"><span class="hs-identifier hs-var">Set.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616904"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-372"></span><span>
</span><span id="line-373"></span><span class="hs-comment">-- | A total variant of 'head'.</span><span>
</span><span id="line-374"></span><span class="hs-comment">--</span><span>
</span><span id="line-375"></span><span class="hs-comment">-- @since 3.2.0.0</span><span>
</span><span id="line-376"></span><span id="local-6989586621679617282"><span class="annot"><a href="Distribution.Utils.Generic.html#safeHead"><span class="hs-identifier hs-type">safeHead</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617282"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679617282"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-377"></span><span id="safeHead"><span class="annot"><span class="annottext">safeHead :: forall a. [a] -&gt; Maybe a
</span><a href="Distribution.Utils.Generic.html#safeHead"><span class="hs-identifier hs-var hs-var">safeHead</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-378"></span><span class="annot"><a href="Distribution.Utils.Generic.html#safeHead"><span class="hs-identifier hs-var">safeHead</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616901"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616901"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[a]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; Maybe a
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616901"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-379"></span><span>
</span><span id="line-380"></span><span class="hs-comment">-- | A total variant of 'tail'.</span><span>
</span><span id="line-381"></span><span class="hs-comment">--</span><span>
</span><span id="line-382"></span><span class="hs-comment">-- @since 3.2.0.0</span><span>
</span><span id="line-383"></span><span id="local-6989586621679616900"><span class="annot"><a href="Distribution.Utils.Generic.html#safeTail"><span class="hs-identifier hs-type">safeTail</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616900"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616900"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-384"></span><span id="safeTail"><span class="annot"><span class="annottext">safeTail :: forall a. [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#safeTail"><span class="hs-identifier hs-var hs-var">safeTail</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-385"></span><span class="annot"><a href="Distribution.Utils.Generic.html#safeTail"><span class="hs-identifier hs-var">safeTail</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616899"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616899"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616899"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-386"></span><span>
</span><span id="line-387"></span><span class="hs-comment">-- | A total variant of 'last'.</span><span>
</span><span id="line-388"></span><span class="hs-comment">--</span><span>
</span><span id="line-389"></span><span class="hs-comment">-- @since 3.2.0.0</span><span>
</span><span id="line-390"></span><span id="local-6989586621679616898"><span class="annot"><a href="Distribution.Utils.Generic.html#safeLast"><span class="hs-identifier hs-type">safeLast</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616898"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679616898"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-391"></span><span id="safeLast"><span class="annot"><span class="annottext">safeLast :: forall a. [a] -&gt; Maybe a
</span><a href="Distribution.Utils.Generic.html#safeLast"><span class="hs-identifier hs-var hs-var">safeLast</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-392"></span><span class="annot"><a href="Distribution.Utils.Generic.html#safeLast"><span class="hs-identifier hs-var">safeLast</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616896"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616896"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616895"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616895"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; Maybe a
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; a -&gt; a) -&gt; a -&gt; [a] -&gt; a
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl"><span class="hs-identifier hs-var">foldl</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679616893"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616893"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616893"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616896"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616895"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-393"></span><span>
</span><span id="line-394"></span><span class="hs-comment">-- | A total variant of 'init'.</span><span>
</span><span id="line-395"></span><span class="hs-comment">--</span><span>
</span><span id="line-396"></span><span class="hs-comment">-- @since 3.2.0.0</span><span>
</span><span id="line-397"></span><span id="local-6989586621679616892"><span class="annot"><a href="Distribution.Utils.Generic.html#safeInit"><span class="hs-identifier hs-type">safeInit</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616892"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679616892"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-398"></span><span id="safeInit"><span class="annot"><span class="annottext">safeInit :: forall a. [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#safeInit"><span class="hs-identifier hs-var hs-var">safeInit</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-399"></span><span class="annot"><a href="Distribution.Utils.Generic.html#safeInit"><span class="hs-identifier hs-var">safeInit</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">]</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-400"></span><span class="annot"><a href="Distribution.Utils.Generic.html#safeInit"><span class="hs-identifier hs-var">safeInit</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616891"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616891"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616890"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616890"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616891"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a]
forall a. [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#safeInit"><span class="hs-identifier hs-var">safeInit</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616890"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-401"></span><span>
</span><span id="line-402"></span><span id="local-6989586621679617274"><span id="local-6989586621679617275"><span class="annot"><a href="Distribution.Utils.Generic.html#equating"><span class="hs-identifier hs-type">equating</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Eq</span></span><span> </span><span class="annot"><a href="#local-6989586621679617275"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617274"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679617275"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679617274"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679617274"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span></span><span>
</span><span id="line-403"></span><span id="equating"><span class="annot"><span class="annottext">equating :: forall a b. Eq a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#equating"><span class="hs-identifier hs-var hs-var">equating</span></a></span></span><span> </span><span id="local-6989586621679616887"><span class="annot"><span class="annottext">b -&gt; a
</span><a href="#local-6989586621679616887"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679616886"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616886"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679616885"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616885"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b -&gt; a
</span><a href="#local-6989586621679616887"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616886"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; a -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">b -&gt; a
</span><a href="#local-6989586621679616887"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616885"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-404"></span><span>
</span><span id="line-405"></span><span class="hs-comment">-- | Lower case string</span><span>
</span><span id="line-406"></span><span class="hs-comment">--</span><span>
</span><span id="line-407"></span><span class="hs-comment">-- &gt;&gt;&gt; lowercase &quot;Foobar&quot;</span><span>
</span><span id="line-408"></span><span class="hs-comment">-- &quot;foobar&quot;</span><span>
</span><span id="line-409"></span><span class="annot"><a href="Distribution.Utils.Generic.html#lowercase"><span class="hs-identifier hs-type">lowercase</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-410"></span><span id="lowercase"><span class="annot"><span class="annottext">lowercase :: String -&gt; String
</span><a href="Distribution.Utils.Generic.html#lowercase"><span class="hs-identifier hs-var hs-var">lowercase</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Char) -&gt; String -&gt; String
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char
</span><a href="../../base/src/GHC.Unicode.html#toLower"><span class="hs-identifier hs-var">toLower</span></a></span><span>
</span><span id="line-411"></span><span>
</span><span id="line-412"></span><span class="hs-comment">-- | Ascii characters</span><span>
</span><span id="line-413"></span><span class="annot"><a href="Distribution.Utils.Generic.html#isAscii"><span class="hs-identifier hs-type">isAscii</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-414"></span><span id="isAscii"><span class="annot"><span class="annottext">isAscii :: Char -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#isAscii"><span class="hs-identifier hs-var hs-var">isAscii</span></a></span></span><span> </span><span id="local-6989586621679616883"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616883"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
forall a. Enum a =&gt; a -&gt; Int
</span><a href="../../base/src/GHC.Enum.html#fromEnum"><span class="hs-identifier hs-var">fromEnum</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616883"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x80</span></span><span>
</span><span id="line-415"></span><span>
</span><span id="line-416"></span><span class="hs-comment">-- | Ascii letters.</span><span>
</span><span id="line-417"></span><span class="annot"><a href="Distribution.Utils.Generic.html#isAsciiAlpha"><span class="hs-identifier hs-type">isAsciiAlpha</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-418"></span><span id="isAsciiAlpha"><span class="annot"><span class="annottext">isAsciiAlpha :: Char -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#isAsciiAlpha"><span class="hs-identifier hs-var hs-var">isAsciiAlpha</span></a></span></span><span> </span><span id="local-6989586621679616881"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616881"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'a'</span></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616881"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616881"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'z'</span></span><span class="hs-special">)</span><span>
</span><span id="line-419"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'A'</span></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616881"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616881"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'Z'</span></span><span class="hs-special">)</span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span class="hs-comment">-- | Ascii letters and digits.</span><span>
</span><span id="line-422"></span><span class="hs-comment">--</span><span>
</span><span id="line-423"></span><span class="hs-comment">-- &gt;&gt;&gt; isAsciiAlphaNum 'a'</span><span>
</span><span id="line-424"></span><span class="hs-comment">-- True</span><span>
</span><span id="line-425"></span><span class="hs-comment">--</span><span>
</span><span id="line-426"></span><span class="hs-comment">-- &gt;&gt;&gt; isAsciiAlphaNum '&#228;'</span><span>
</span><span id="line-427"></span><span class="hs-comment">-- False</span><span>
</span><span id="line-428"></span><span class="hs-comment">--</span><span>
</span><span id="line-429"></span><span class="annot"><a href="Distribution.Utils.Generic.html#isAsciiAlphaNum"><span class="hs-identifier hs-type">isAsciiAlphaNum</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-430"></span><span id="isAsciiAlphaNum"><span class="annot"><span class="annottext">isAsciiAlphaNum :: Char -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#isAsciiAlphaNum"><span class="hs-identifier hs-var hs-var">isAsciiAlphaNum</span></a></span></span><span> </span><span id="local-6989586621679616880"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616880"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#isAscii"><span class="hs-identifier hs-var">isAscii</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616880"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../base/src/GHC.Unicode.html#isAlphaNum"><span class="hs-identifier hs-var">isAlphaNum</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616880"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-431"></span><span>
</span><span id="line-432"></span><span class="annot"><a href="Distribution.Utils.Generic.html#unintersperse"><span class="hs-identifier hs-type">unintersperse</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-433"></span><span id="unintersperse"><span class="annot"><span class="annottext">unintersperse :: Char -&gt; String -&gt; [String]
</span><a href="Distribution.Utils.Generic.html#unintersperse"><span class="hs-identifier hs-var hs-var">unintersperse</span></a></span></span><span> </span><span id="local-6989586621679616878"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616878"><span class="hs-identifier hs-var">mark</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Maybe (String, String)) -&gt; String -&gt; [String]
forall b a. (b -&gt; Maybe (a, b)) -&gt; b -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#unfoldr"><span class="hs-identifier hs-var">unfoldr</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe (String, String)
</span><a href="#local-6989586621679616876"><span class="hs-identifier hs-var">unintersperse1</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-434"></span><span>  </span><span id="local-6989586621679616876"><span class="annot"><span class="annottext">unintersperse1 :: String -&gt; Maybe (String, String)
</span><a href="#local-6989586621679616876"><span class="hs-identifier hs-var hs-var">unintersperse1</span></a></span></span><span> </span><span id="local-6989586621679616874"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616874"><span class="hs-identifier hs-var">str</span></a></span></span><span>
</span><span id="line-435"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616874"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (String, String)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-436"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-437"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616871"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616871"><span class="hs-identifier hs-var">this</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679616870"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616870"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; (String, String)
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/GHC.List.html#break"><span class="hs-identifier hs-var">break</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616878"><span class="hs-identifier hs-var">mark</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616874"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="hs-keyword">in</span><span>
</span><span id="line-438"></span><span>        </span><span class="annot"><span class="annottext">(String, String) -&gt; Maybe (String, String)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616871"><span class="hs-identifier hs-var">this</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; String
forall a. [a] -&gt; [a]
</span><a href="Distribution.Utils.Generic.html#safeTail"><span class="hs-identifier hs-var">safeTail</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679616870"><span class="hs-identifier hs-var">rest</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-439"></span><span>
</span><span id="line-440"></span><span class="hs-comment">-- | Like 'break', but with 'Maybe' predicate</span><span>
</span><span id="line-441"></span><span class="hs-comment">--</span><span>
</span><span id="line-442"></span><span class="hs-comment">-- &gt;&gt;&gt; breakMaybe (readMaybe :: String -&gt; Maybe Int) [&quot;foo&quot;, &quot;bar&quot;, &quot;1&quot;, &quot;2&quot;, &quot;quu&quot;]</span><span>
</span><span id="line-443"></span><span class="hs-comment">-- ([&quot;foo&quot;,&quot;bar&quot;],Just (1,[&quot;2&quot;,&quot;quu&quot;]))</span><span>
</span><span id="line-444"></span><span class="hs-comment">--</span><span>
</span><span id="line-445"></span><span class="hs-comment">-- &gt;&gt;&gt; breakMaybe (readMaybe :: String -&gt; Maybe Int) [&quot;foo&quot;, &quot;bar&quot;]</span><span>
</span><span id="line-446"></span><span class="hs-comment">-- ([&quot;foo&quot;,&quot;bar&quot;],Nothing)</span><span>
</span><span id="line-447"></span><span class="hs-comment">--</span><span>
</span><span id="line-448"></span><span class="hs-comment">-- @since 2.2</span><span>
</span><span id="line-449"></span><span class="hs-comment">--</span><span>
</span><span id="line-450"></span><span id="local-6989586621679617266"><span id="local-6989586621679617267"><span class="annot"><a href="Distribution.Utils.Generic.html#breakMaybe"><span class="hs-identifier hs-type">breakMaybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617267"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679617266"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617267"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617267"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617266"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617267"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span></span></span><span>
</span><span id="line-451"></span><span id="breakMaybe"><span class="annot"><span class="annottext">breakMaybe :: forall a b. (a -&gt; Maybe b) -&gt; [a] -&gt; ([a], Maybe (b, [a]))
</span><a href="Distribution.Utils.Generic.html#breakMaybe"><span class="hs-identifier hs-var hs-var">breakMaybe</span></a></span></span><span> </span><span id="local-6989586621679616868"><span class="annot"><span class="annottext">a -&gt; Maybe b
</span><a href="#local-6989586621679616868"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([a] -&gt; [a]) -&gt; [a] -&gt; ([a], Maybe (b, [a]))
forall {c}. ([a] -&gt; c) -&gt; [a] -&gt; (c, Maybe (b, [a]))
</span><a href="#local-6989586621679616867"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a]
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-452"></span><span>    </span><span id="local-6989586621679616867"><span class="annot"><span class="annottext">go :: ([a] -&gt; c) -&gt; [a] -&gt; (c, Maybe (b, [a]))
</span><a href="#local-6989586621679616867"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679616866"><span class="annot"><span class="annottext">[a] -&gt; c
</span><a href="#local-6989586621679616866"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[a] -&gt; c
</span><a href="#local-6989586621679616866"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (b, [a])
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-453"></span><span>    </span><span class="annot"><a href="#local-6989586621679616867"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679616865"><span class="annot"><span class="annottext">[a] -&gt; c
</span><a href="#local-6989586621679616865"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616864"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616864"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616863"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616863"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">a -&gt; Maybe b
</span><a href="#local-6989586621679616868"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616864"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-454"></span><span>        </span><span class="annot"><span class="annottext">Maybe b
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">([a] -&gt; c) -&gt; [a] -&gt; (c, Maybe (b, [a]))
</span><a href="#local-6989586621679616867"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[a] -&gt; c
</span><a href="#local-6989586621679616865"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">([a] -&gt; c) -&gt; ([a] -&gt; [a]) -&gt; [a] -&gt; c
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616864"><span class="hs-identifier hs-var">x</span></a></span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616863"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-455"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679616862"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616862"><span class="hs-identifier hs-var">b</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[a] -&gt; c
</span><a href="#local-6989586621679616865"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(b, [a]) -&gt; Maybe (b, [a])
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616862"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616863"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-456"></span><span>
</span><span id="line-457"></span><span class="hs-comment">-- | Like 'span' but with 'Maybe' predicate</span><span>
</span><span id="line-458"></span><span class="hs-comment">--</span><span>
</span><span id="line-459"></span><span class="hs-comment">-- &gt;&gt;&gt; spanMaybe listToMaybe [[1,2],[3],[],[4,5],[6,7]]</span><span>
</span><span id="line-460"></span><span class="hs-comment">-- ([1,3],[[],[4,5],[6,7]])</span><span>
</span><span id="line-461"></span><span class="hs-comment">--</span><span>
</span><span id="line-462"></span><span class="hs-comment">-- &gt;&gt;&gt; spanMaybe (readMaybe :: String -&gt; Maybe Int) [&quot;1&quot;, &quot;2&quot;, &quot;foo&quot;]</span><span>
</span><span id="line-463"></span><span class="hs-comment">-- ([1,2],[&quot;foo&quot;])</span><span>
</span><span id="line-464"></span><span class="hs-comment">--</span><span>
</span><span id="line-465"></span><span class="hs-comment">-- @since 2.2</span><span>
</span><span id="line-466"></span><span class="hs-comment">--</span><span>
</span><span id="line-467"></span><span id="local-6989586621679617261"><span id="local-6989586621679617262"><span class="annot"><a href="Distribution.Utils.Generic.html#spanMaybe"><span class="hs-identifier hs-type">spanMaybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617262"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679617261"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617262"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617261"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617262"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span></span></span><span>
</span><span id="line-468"></span><span id="spanMaybe"><span class="annot"><span class="annottext">spanMaybe :: forall a b. (a -&gt; Maybe b) -&gt; [a] -&gt; ([b], [a])
</span><a href="Distribution.Utils.Generic.html#spanMaybe"><span class="hs-identifier hs-var hs-var">spanMaybe</span></a></span></span><span> </span><span class="annot"><span class="annottext">a -&gt; Maybe b
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679616861"><span class="annot"><span class="annottext">xs :: [a]
</span><a href="#local-6989586621679616861"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616861"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-469"></span><span class="annot"><a href="Distribution.Utils.Generic.html#spanMaybe"><span class="hs-identifier hs-var">spanMaybe</span></a></span><span> </span><span id="local-6989586621679616860"><span class="annot"><span class="annottext">a -&gt; Maybe b
</span><a href="#local-6989586621679616860"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679616859"><span class="annot"><span class="annottext">xs :: [a]
</span><a href="#local-6989586621679616859"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621679616858"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616858"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616857"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616857"><span class="hs-identifier hs-var">xs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">a -&gt; Maybe b
</span><a href="#local-6989586621679616860"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616858"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-470"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679616856"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616856"><span class="hs-identifier hs-var">y</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616855"><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621679616855"><span class="hs-identifier hs-var">ys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679616854"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616854"><span class="hs-identifier hs-var">zs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; Maybe b) -&gt; [a] -&gt; ([b], [a])
forall a b. (a -&gt; Maybe b) -&gt; [a] -&gt; ([b], [a])
</span><a href="Distribution.Utils.Generic.html#spanMaybe"><span class="hs-identifier hs-var">spanMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Maybe b
</span><a href="#local-6989586621679616860"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616857"><span class="hs-identifier hs-var">xs'</span></a></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616856"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">b -&gt; [b] -&gt; [b]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621679616855"><span class="hs-identifier hs-var">ys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616854"><span class="hs-identifier hs-var">zs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-471"></span><span>    </span><span class="annot"><span class="annottext">Maybe b
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616859"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span class="hs-comment">-- | 'unfoldr' with monadic action.</span><span>
</span><span id="line-474"></span><span class="hs-comment">--</span><span>
</span><span id="line-475"></span><span class="hs-comment">-- &gt;&gt;&gt; take 5 $ unfoldrM (\b r -&gt; Just (r + b, b + 1)) (1 :: Int) 2</span><span>
</span><span id="line-476"></span><span class="hs-comment">-- [3,4,5,6,7]</span><span>
</span><span id="line-477"></span><span class="hs-comment">--</span><span>
</span><span id="line-478"></span><span class="hs-comment">-- @since 2.2</span><span>
</span><span id="line-479"></span><span class="hs-comment">--</span><span>
</span><span id="line-480"></span><span id="local-6989586621679617256"><span id="local-6989586621679617257"><span id="local-6989586621679617258"><span class="annot"><a href="Distribution.Utils.Generic.html#unfoldrM"><span class="hs-identifier hs-type">unfoldrM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679617258"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617257"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679617258"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617256"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679617257"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679617257"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679617258"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617256"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span></span></span><span>
</span><span id="line-481"></span><span id="unfoldrM"><span class="annot"><span class="annottext">unfoldrM :: forall (m :: * -&gt; *) b a.
Monad m =&gt;
(b -&gt; m (Maybe (a, b))) -&gt; b -&gt; m [a]
</span><a href="Distribution.Utils.Generic.html#unfoldrM"><span class="hs-identifier hs-var hs-var">unfoldrM</span></a></span></span><span> </span><span id="local-6989586621679616852"><span class="annot"><span class="annottext">b -&gt; m (Maybe (a, b))
</span><a href="#local-6989586621679616852"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b -&gt; m [a]
</span><a href="#local-6989586621679616851"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-482"></span><span>    </span><span id="local-6989586621679616851"><span class="annot"><span class="annottext">go :: b -&gt; m [a]
</span><a href="#local-6989586621679616851"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679616847"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616847"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-483"></span><span>        </span><span id="local-6989586621679616846"><span class="annot"><span class="annottext">Maybe (a, b)
</span><a href="#local-6989586621679616846"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">b -&gt; m (Maybe (a, b))
</span><a href="#local-6989586621679616852"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616847"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-484"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (a, b)
</span><a href="#local-6989586621679616846"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-485"></span><span>            </span><span class="annot"><span class="annottext">Maybe (a, b)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; m [a]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-486"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616845"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616845"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679616844"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616844"><span class="hs-identifier hs-var">b'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">([a] -&gt; [a]) -&gt; m [a] -&gt; m [a]
forall (m :: * -&gt; *) a1 r. Monad m =&gt; (a1 -&gt; r) -&gt; m a1 -&gt; m r
</span><a href="../../base/src/GHC.Base.html#liftM"><span class="hs-identifier hs-var">liftM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616845"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b -&gt; m [a]
</span><a href="#local-6989586621679616851"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616844"><span class="hs-identifier hs-var">b'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-487"></span><span>
</span><span id="line-488"></span><span class="hs-comment">-- | The opposite of 'snoc', which is the reverse of 'cons'</span><span>
</span><span id="line-489"></span><span class="hs-comment">--</span><span>
</span><span id="line-490"></span><span class="hs-comment">-- Example:</span><span>
</span><span id="line-491"></span><span class="hs-comment">--</span><span>
</span><span id="line-492"></span><span class="hs-comment">-- &gt;&gt;&gt; unsnoc [1, 2, 3]</span><span>
</span><span id="line-493"></span><span class="hs-comment">-- Just ([1,2],3)</span><span>
</span><span id="line-494"></span><span class="hs-comment">--</span><span>
</span><span id="line-495"></span><span class="hs-comment">-- &gt;&gt;&gt; unsnoc []</span><span>
</span><span id="line-496"></span><span class="hs-comment">-- Nothing</span><span>
</span><span id="line-497"></span><span class="hs-comment">--</span><span>
</span><span id="line-498"></span><span class="hs-comment">-- @since 3.2.0.0</span><span>
</span><span id="line-499"></span><span class="hs-comment">--</span><span>
</span><span id="line-500"></span><span id="local-6989586621679617248"><span class="annot"><a href="Distribution.Utils.Generic.html#unsnoc"><span class="hs-identifier hs-type">unsnoc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617248"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617248"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679617248"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-501"></span><span id="unsnoc"><span class="annot"><span class="annottext">unsnoc :: forall a. [a] -&gt; Maybe ([a], a)
</span><a href="Distribution.Utils.Generic.html#unsnoc"><span class="hs-identifier hs-var hs-var">unsnoc</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe ([a], a)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-502"></span><span class="annot"><a href="Distribution.Utils.Generic.html#unsnoc"><span class="hs-identifier hs-var">unsnoc</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616842"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616842"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616841"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616841"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([a], a) -&gt; Maybe ([a], a)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NonEmpty a -&gt; ([a], a)
forall a. NonEmpty a -&gt; ([a], a)
</span><a href="Distribution.Utils.Generic.html#unsnocNE"><span class="hs-identifier hs-var">unsnocNE</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616842"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; NonEmpty a
forall a. a -&gt; [a] -&gt; NonEmpty a
</span><a href="../../base/src/GHC.Base.html#%3A%7C"><span class="hs-operator hs-var">:|</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616841"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-503"></span><span>
</span><span id="line-504"></span><span class="hs-comment">-- | Like 'unsnoc', but for 'NonEmpty' so without the 'Maybe'</span><span>
</span><span id="line-505"></span><span class="hs-comment">--</span><span>
</span><span id="line-506"></span><span class="hs-comment">-- Example:</span><span>
</span><span id="line-507"></span><span class="hs-comment">--</span><span>
</span><span id="line-508"></span><span class="hs-comment">-- &gt;&gt;&gt; unsnocNE (1 :| [2, 3])</span><span>
</span><span id="line-509"></span><span class="hs-comment">-- ([1,2],3)</span><span>
</span><span id="line-510"></span><span class="hs-comment">--</span><span>
</span><span id="line-511"></span><span class="hs-comment">-- &gt;&gt;&gt; unsnocNE (1 :| [])</span><span>
</span><span id="line-512"></span><span class="hs-comment">-- ([],1)</span><span>
</span><span id="line-513"></span><span class="hs-comment">--</span><span>
</span><span id="line-514"></span><span class="hs-comment">-- @since 3.2.0.0</span><span>
</span><span id="line-515"></span><span class="hs-comment">--</span><span>
</span><span id="line-516"></span><span id="local-6989586621679617245"><span class="annot"><a href="Distribution.Utils.Generic.html#unsnocNE"><span class="hs-identifier hs-type">unsnocNE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#NonEmpty"><span class="hs-identifier hs-type">NonEmpty</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679617245"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679617245"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679617245"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-517"></span><span id="unsnocNE"><span class="annot"><span class="annottext">unsnocNE :: forall a. NonEmpty a -&gt; ([a], a)
</span><a href="Distribution.Utils.Generic.html#unsnocNE"><span class="hs-identifier hs-var hs-var">unsnocNE</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616839"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616839"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><a href="../../base/src/GHC.Base.html#%3A%7C"><span class="hs-operator hs-type">:|</span></a></span><span id="local-6989586621679616838"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616838"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; ([a], a)
forall {a}. a -&gt; [a] -&gt; ([a], a)
</span><a href="#local-6989586621679616837"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616839"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616838"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-518"></span><span>    </span><span id="local-6989586621679616837"><span class="annot"><span class="annottext">go :: a -&gt; [a] -&gt; ([a], a)
</span><a href="#local-6989586621679616837"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679616836"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616836"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616836"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-519"></span><span>    </span><span class="annot"><a href="#local-6989586621679616837"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621679616835"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616835"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616834"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616834"><span class="hs-identifier hs-var">z</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679616833"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616833"><span class="hs-identifier hs-var">zs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">~</span><span class="hs-special">(</span><span id="local-6989586621679616832"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616832"><span class="hs-identifier hs-var">ws</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679616831"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616831"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; ([a], a)
</span><a href="#local-6989586621679616837"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616834"><span class="hs-identifier hs-var">z</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616833"><span class="hs-identifier hs-var">zs</span></a></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616835"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679616832"><span class="hs-identifier hs-var">ws</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616831"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-520"></span><span>
</span><span id="line-521"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-522"></span><span class="hs-comment">-- Triples</span><span>
</span><span id="line-523"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-524"></span><span>
</span><span id="line-525"></span><span class="hs-comment">-- | @since 3.4.0.0</span><span>
</span><span id="line-526"></span><span id="local-6989586621679617239"><span id="local-6989586621679617240"><span id="local-6989586621679617241"><span class="annot"><a href="Distribution.Utils.Generic.html#fstOf3"><span class="hs-identifier hs-type">fstOf3</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617241"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679617240"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679617239"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679617241"><span class="hs-identifier hs-type">a</span></a></span></span></span></span><span>
</span><span id="line-527"></span><span id="fstOf3"><span class="annot"><span class="annottext">fstOf3 :: forall a b c. (a, b, c) -&gt; a
</span><a href="Distribution.Utils.Generic.html#fstOf3"><span class="hs-identifier hs-var hs-var">fstOf3</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616830"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616830"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">c
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679616830"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-528"></span><span>
</span><span id="line-529"></span><span class="hs-comment">-- | @since 3.4.0.0</span><span>
</span><span id="line-530"></span><span id="local-6989586621679617233"><span id="local-6989586621679617234"><span id="local-6989586621679617235"><span class="annot"><a href="Distribution.Utils.Generic.html#sndOf3"><span class="hs-identifier hs-type">sndOf3</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617235"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679617234"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679617233"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679617234"><span class="hs-identifier hs-type">b</span></a></span></span></span></span><span>
</span><span id="line-531"></span><span id="sndOf3"><span class="annot"><span class="annottext">sndOf3 :: forall a b c. (a, b, c) -&gt; b
</span><a href="Distribution.Utils.Generic.html#sndOf3"><span class="hs-identifier hs-var hs-var">sndOf3</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679616829"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616829"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">c
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679616829"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-532"></span><span>
</span><span id="line-533"></span><span class="hs-comment">-- | @since 3.4.0.0</span><span>
</span><span id="line-534"></span><span id="local-6989586621679617227"><span id="local-6989586621679617228"><span id="local-6989586621679617229"><span class="annot"><a href="Distribution.Utils.Generic.html#trdOf3"><span class="hs-identifier hs-type">trdOf3</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679617229"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679617228"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679617227"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679617227"><span class="hs-identifier hs-type">c</span></a></span></span></span></span><span>
</span><span id="line-535"></span><span id="trdOf3"><span class="annot"><span class="annottext">trdOf3 :: forall a b c. (a, b, c) -&gt; c
</span><a href="Distribution.Utils.Generic.html#trdOf3"><span class="hs-identifier hs-var hs-var">trdOf3</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679616828"><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621679616828"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621679616828"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-536"></span><span>
</span><span id="line-537"></span><span class="hs-comment">-- ------------------------------------------------------------</span><span>
</span><span id="line-538"></span><span class="hs-comment">-- * FilePath stuff</span><span>
</span><span id="line-539"></span><span class="hs-comment">-- ------------------------------------------------------------</span><span>
</span><span id="line-540"></span><span>
</span><span id="line-541"></span><span class="hs-comment">-- | 'isAbsoluteOnAnyPlatform' and 'isRelativeOnAnyPlatform' are like</span><span>
</span><span id="line-542"></span><span class="hs-comment">-- 'System.FilePath.isAbsolute' and 'System.FilePath.isRelative' but have</span><span>
</span><span id="line-543"></span><span class="hs-comment">-- platform independent heuristics.</span><span>
</span><span id="line-544"></span><span class="hs-comment">-- The System.FilePath exists in two versions, Windows and Posix. The two</span><span>
</span><span id="line-545"></span><span class="hs-comment">-- versions don't agree on what is a relative path and we don't know if we're</span><span>
</span><span id="line-546"></span><span class="hs-comment">-- given Windows or Posix paths.</span><span>
</span><span id="line-547"></span><span class="hs-comment">-- This results in false positives when running on Posix and inspecting</span><span>
</span><span id="line-548"></span><span class="hs-comment">-- Windows paths, like the hackage server does.</span><span>
</span><span id="line-549"></span><span class="hs-comment">-- System.FilePath.Posix.isAbsolute \&quot;C:\\hello\&quot; == False</span><span>
</span><span id="line-550"></span><span class="hs-comment">-- System.FilePath.Windows.isAbsolute \&quot;/hello\&quot; == False</span><span>
</span><span id="line-551"></span><span class="hs-comment">-- This means that we would treat paths that start with \&quot;/\&quot; to be absolute.</span><span>
</span><span id="line-552"></span><span class="hs-comment">-- On Posix they are indeed absolute, while on Windows they are not.</span><span>
</span><span id="line-553"></span><span class="hs-comment">--</span><span>
</span><span id="line-554"></span><span class="hs-comment">-- The portable versions should be used when we might deal with paths that</span><span>
</span><span id="line-555"></span><span class="hs-comment">-- are from another OS than the host OS. For example, the Hackage Server</span><span>
</span><span id="line-556"></span><span class="hs-comment">-- deals with both Windows and Posix paths while performing the</span><span>
</span><span id="line-557"></span><span class="hs-comment">-- PackageDescription checks. In contrast, when we run 'cabal configure' we</span><span>
</span><span id="line-558"></span><span class="hs-comment">-- do expect the paths to be correct for our OS and we should not have to use</span><span>
</span><span id="line-559"></span><span class="hs-comment">-- the platform independent heuristics.</span><span>
</span><span id="line-560"></span><span class="annot"><a href="Distribution.Utils.Generic.html#isAbsoluteOnAnyPlatform"><span class="hs-identifier hs-type">isAbsoluteOnAnyPlatform</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-561"></span><span class="hs-comment">-- C:\\directory</span><span>
</span><span id="line-562"></span><span id="isAbsoluteOnAnyPlatform"><span class="annot"><span class="annottext">isAbsoluteOnAnyPlatform :: String -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#isAbsoluteOnAnyPlatform"><span class="hs-identifier hs-var hs-var">isAbsoluteOnAnyPlatform</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616827"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616827"><span class="hs-identifier hs-var">drive</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">':'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\\'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../base/src/GHC.Unicode.html#isAlpha"><span class="hs-identifier hs-var">isAlpha</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616827"><span class="hs-identifier hs-var">drive</span></a></span><span>
</span><span id="line-563"></span><span class="annot"><a href="Distribution.Utils.Generic.html#isAbsoluteOnAnyPlatform"><span class="hs-identifier hs-var">isAbsoluteOnAnyPlatform</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679616825"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616825"><span class="hs-identifier hs-var">drive</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">':'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'/'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../base/src/GHC.Unicode.html#isAlpha"><span class="hs-identifier hs-var">isAlpha</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679616825"><span class="hs-identifier hs-var">drive</span></a></span><span>
</span><span id="line-564"></span><span class="hs-comment">-- UNC</span><span>
</span><span id="line-565"></span><span class="annot"><a href="Distribution.Utils.Generic.html#isAbsoluteOnAnyPlatform"><span class="hs-identifier hs-var">isAbsoluteOnAnyPlatform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\\'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\\'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-566"></span><span class="hs-comment">-- Posix root</span><span>
</span><span id="line-567"></span><span class="annot"><a href="Distribution.Utils.Generic.html#isAbsoluteOnAnyPlatform"><span class="hs-identifier hs-var">isAbsoluteOnAnyPlatform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'/'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-568"></span><span class="annot"><a href="Distribution.Utils.Generic.html#isAbsoluteOnAnyPlatform"><span class="hs-identifier hs-var">isAbsoluteOnAnyPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-569"></span><span>
</span><span id="line-570"></span><span class="hs-comment">-- | @isRelativeOnAnyPlatform = not . 'isAbsoluteOnAnyPlatform'@</span><span>
</span><span id="line-571"></span><span class="annot"><a href="Distribution.Utils.Generic.html#isRelativeOnAnyPlatform"><span class="hs-identifier hs-type">isRelativeOnAnyPlatform</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-572"></span><span id="isRelativeOnAnyPlatform"><span class="annot"><span class="annottext">isRelativeOnAnyPlatform :: String -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#isRelativeOnAnyPlatform"><span class="hs-identifier hs-var hs-var">isRelativeOnAnyPlatform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; (String -&gt; Bool) -&gt; String -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#isAbsoluteOnAnyPlatform"><span class="hs-identifier hs-var">isAbsoluteOnAnyPlatform</span></a></span><span>
</span><span id="line-573"></span><span>
</span><span id="line-574"></span><span class="hs-comment">-- $setup</span><span>
</span><span id="line-575"></span><span class="hs-comment">-- &gt;&gt;&gt; import Data.Maybe</span><span>
</span><span id="line-576"></span><span class="hs-comment">-- &gt;&gt;&gt; import Text.Read</span><span>
</span><span id="line-577"></span></pre></body></html>